using System;
using System.Collections.Generic;
using System.Text;

namespace Ricciolo.PaperBoy.Feeds
{
    public abstract class FeedBase : NotifyItem
    {
        internal readonly FeedsManager feedsManager;

        private string _path;

        protected FeedBase(FeedsManager feedsManager, string path)
            : base(feedsManager.dispatcher)
        {
            if (feedsManager == null)
                throw new ArgumentNullException("feedsManager");
            if (path == null)
                throw new ArgumentNullException("path");
            this._path = path;
            this.feedsManager = feedsManager;

            // Add to the main list
            feedsManager.allfeeds[path] = new WeakReference(this);

            this.Refresh();
        }

        /// <summary>
        /// Retrieves the path for the current feed
        /// </summary>
        public string Path
        {
            get { return _path; }
            set
            {
                _path = value;
                this.Refresh();
            }
        }

        public abstract string Type
        {
            get;
        }

        protected abstract void Refresh();
    }
}
